from sqlalchemy import Column, BigInteger, String, DateTime, Date, Enum, Integer
from sqlalchemy.ext.declarative import declarative_base
from datetime import datetime

Base = declarative_base()

class User(Base):
    __tablename__ = "users"

    id = Column(BigInteger, primary_key=True, autoincrement=True)
    username = Column(String(50), unique=True, nullable=True)
    email = Column(String(100), unique=True, nullable=True)
    phone = Column(String(20), unique=True, nullable=True)
    hashed_password = Column(String(60), nullable=True)
    password = Column(String(20), unique=True, nullable=True)  # 建议删除此字段

    nickname = Column(String(50), nullable=False, default='')
    avatar_url = Column(String(255), nullable=True)

    status = Column(Integer, nullable=False, default=1)  # 状态: 1=正常, 2=禁用
    created_at = Column(DateTime, nullable=True)
    updated_at = Column(DateTime, nullable=True)

    last_login_date = Column(DateTime, nullable=True)
    login_count = Column(Integer, nullable=False, default=0)
    birthday = Column(Date, nullable=True)
    gender = Column(Enum("male", "female", "other"), nullable=True, default="other")